package com.ibeeking.found.file.rest.controller.v1;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ibeeking.found.file.rest.service.ISysParamService;
import com.ibeeking.found.file.service.common.dos.SysParamDO;
import com.ibeeking.found.file.service.common.param.QueryGroupParam;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @ClassName SysParamController
 * @Description 系统参数管理
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/param/v1")
public class SysParamController {

    @Resource
    private ISysParamService sysParamServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询系统参数组")
    @GetMapping(value = "/grouplist")
    public Map groupList(@RequestBody QueryGroupParam queryGroupParamDTO) {
        List<SysParamDO> list = sysParamServiceImpl.list(new QueryWrapper<SysParamDO>().lambda().eq(SysParamDO::getGroupName, queryGroupParamDTO.getGroupName()));
        Map<String, Object> result = new HashMap<>();

        for (SysParamDO sysParam : list) {
            result.put(sysParam.getParamKey(), sysParam.getParamValue());
        }

        return result;
    }


}
